$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    console.log('detail Ready');
    var mstform = $NG.getCmpApi('p_form_tbjdfxpg_m');
    if (page.oType == "add") {
        mstform.getItem('u_basp').setValue('分公司')
    }
    useValuesChange(({ args }) => {
        let u_bdmc = mstform.getItem('u_bdmc').getValue();
        console.log("当前BDMC值:", u_bdmc);
        $NG.execServer("searchNew", { user_bdmc: u_bdmc }, (res2) => {
            if (res2.count === 0) return;
            const xmmsData = JSON.parse(res2.data)[0].extendObjects;
            console.log(xmmsData);

            $NG.updateState((updater) => {
                updater.data.p_form_tbjdfxpg_m.setProps({
                    u_xmmc: xmmsData.project_name,
                    u_ssdw: xmmsData.user_yzdw,
                    // u_ssdw: {
                    //     value: xmmsData.phid_org,
                    //     label: user_xmms_EXName,
                    // }
                });
            });
        });
    }, "p_form_tbjdfxpg_m.u_bdmc");

    // 校验是否亏损
    const ksBtn = ['u_cszcb', 'u_htje']
    ksBtn.forEach(item => {
        useValuesChange(() => {
            const u_cszcb = mstform.getItem("u_cszcb").getValue()
            if ((Number(u_cszcb) || 0) > (Number(mstform.getItem("u_htje").getValue()) || 0)) {
                mstform.getItem("u_sfks").setValue('01')
            } else {
                mstform.getItem("u_sfks").setValue("02")
            }

        }, "p_form_tbjdfxpg_m."+item)
    })

    function u_lrl() {
        let u_yysr = mstform.getItem('u_yysr').getValue();
        let u_csbhszcb = mstform.getItem('u_csbhszcb').getValue();
        if (u_yysr && u_csbhszcb) {

            let lrl = (u_yysr - u_csbhszcb) / u_yysr;
            mstform.getItem('u_lrl').setValue(lrl)
        }
    }
    u_lrl()
    useValuesChange(({ args }) => {
        u_lrl()

    }, "p_form_tbjdfxpg_m.u_yysr");
    useValuesChange(({ args }) => {

        u_lrl()
    }, "p_form_tbjdfxpg_m.u_csbhszcb");
}, function () {
    console.log('list Ready');
});